package com.woniuxy.project.controller;

import com.woniuxy.commons.request.ResPage;
import com.woniuxy.commons.request.ResponseResult;
import com.woniuxy.project.entity.UserDetails;
import com.woniuxy.project.service.UserDetailsService;
import com.woniuxy.project.vo.UserDetailsVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
@Slf4j
@RestController
@RequestMapping("/userDetails")
public class UserDetailsController {
    @Resource
    private UserDetailsService userDetailsService;

    @GetMapping("/getUserDetailsList")
    public ResponseResult<ResPage<UserDetails>> getUserDetailsList(UserDetailsVo userDetailsVo){
        return new ResponseResult<>(ResponseResult.OK, userDetailsService.getUserDetailsList(userDetailsVo));
    }
    /**
     * 锁定账户
     */
    @PutMapping("/disableAccount/{id}")
    public ResponseResult<Boolean> disableAccount(@PathVariable("id") Integer id){
        return new ResponseResult<>(ResponseResult.OK, userDetailsService.disableAccount(id));
    }
    /**
     * 解锁账户
     */
    @PutMapping("/enableAccount/{id}")
    public ResponseResult<Boolean> enableAccount(@PathVariable("id") Integer id){
        return new ResponseResult<>(ResponseResult.OK, userDetailsService.enableAccount(id));
    }
}
